const web = require("../../module/web"), loger = require("../../module/loger");
let rd = 0;

module.exports.run = (yzm)=>{
	web.run((w)=>{
		let inp = w.window.document.getElementsByName("email");
		if(inp && inp[0]) inp[0].value = global.sdObj.ud[3]+"s";
		inp = w.window.document.getElementsByName("psw");
		if(inp && inp[0]) inp[0].value = global.sdObj.ud[10];
		inp = w.window.document.getElementsByName("npsw");
		if(inp && inp[0]) inp[0].value = global.sdObj.ud[10];
		
		inp = w.window.document.getElementsByName("imgvcode");
		if(inp && inp[0]) inp[0].value = yzm;
		
		//点击登录
		inp = w.window.document.getElementsByClassName("subIco");
		if(inp && inp[0]) inp[0].click();
	},(w)=>{
		let tp = w.window.document.getElementsByClassName("tipInfor");
		for(let i=0;i<tp.length;i++){
			if(tp[i].clientWidth > 0){
				if(tp[i].innerHTML.indexOf("验证码输入错误") > 0 && rd < 2){
					rd++;
					global.sdObj.end = -99;			
				}else{
					global.sdObj.end = 1011;	
					rd = 0;
				}
				return true;
			}
		}
		if(w.window.location.href.indexOf("/classic/index.php") > 0){
			global.sdObj.end = 0;
			return true;
		}
	});
}